import  traceback

try:
    print("step1")
    num = 666/0
except:
    with open("c:/a.txt","a") as f:
        traceback.print_exc(file=f)